<?php

/**
 * Carrera form.
 *
 * @package    sistema_estadisticas
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class CarreraForm extends BaseCarreraForm
{

	public function configure()
	{
		$this->widgetSchema['seccion'] = new sfWidgetFormChoice(array('choices' => Constantes::$SECCIONES)); 
		$this->widgetSchema['modalidad'] = new sfWidgetFormChoice(array('choices' => Constantes::$MODALIDADES));
		$this->validatorSchema['seccion'] = new sfValidatorChoice(array('choices' => array_keys(Constantes::$SECCIONES))); 
		$this->validatorSchema['modalidad'] = new sfValidatorChoice(array('choices' => array_keys(Constantes::$MODALIDADES)));
		$this->validatorSchema['slug'] = new sfValidatorRegex(array('pattern' => '/^[a-z]+[a-z_]*[a-z]+$/'));
	}

	public function doSave($con = null)
	{
		parent::doSave($con);
		if ($this->isNew())
		{
			if (sfContext::hasInstance())
			{
				$c_usuario = new CarreraUsuario();
				$c_usuario->usuario_id = sfContext::getInstance()->getUser()->getUserId();
				$c_usuario->carrera_id = $this->getObject()->id;
				$c_usuario->save($con);
			}
		}
	}

}
